package cn.ywang.spring.orm.datasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * 动态数据源
 *
 * @author BeatificWang
 * @date 2019/5/5 23:07
 */
public class DynamicDataSource extends AbstractRoutingDataSource {

	/**
	 * 为数据源做标记
	 */
	private DynamicDataSourceEntry dataSourceEntry;

	@Override
	protected Object determineCurrentLookupKey() {
		return this.dataSourceEntry.get();
	}

	public void setDataSourceEntry(DynamicDataSourceEntry dataSourceEntry) {
		this.dataSourceEntry = dataSourceEntry;
	}

	public DynamicDataSourceEntry getDataSourceEntry() {
		return this.dataSourceEntry;
	}
}
